package com.xlh.enums.user;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 班级状态枚举
 * <p>
 * Created by lx on 2019/4/22.
 */
@Getter
@AllArgsConstructor
public enum ClassStatusEnum {

    ENDED(true, "已结课"),
    UNFINISHED(false, "未结课");

    private boolean code;

    private String message;

    public static ClassStatusEnum getByCode(Boolean code) {
        for (ClassStatusEnum statusEnum : ClassStatusEnum.values()) {
            if (Objects.equals(statusEnum.isCode(), code)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static ClassStatusEnum getByMessage(String message) {
        for (ClassStatusEnum classStatusEnum : ClassStatusEnum.values()) {
            if (Objects.equals(classStatusEnum.getMessage(), message)) {
                return classStatusEnum;
            }
        }
        return null;
    }
}
